#! /usr/bin/env python
#Copyright (C) 2003-2004 Robert P. Krawczyk
# $Id: main.py,v 1.7 2004/12/17 09:57:49 krawczyk Exp $

"""
Main Program for game!
global variable scr will contain screen surface after Init()!
"""

import os, sys
import pygame
import mixer, config, extras, scroller, snowball, flocke, intro, menu, game
import computerplayer, player


from pygame.locals import *

def Init():
    """Init function."""
    try:
        pygame.init()
    except:
        print "Warning, problems while initialising PyGame."
        pass

    config.Init() #Load configuration File
    #Configure Graphics
    config.scr = pygame.display.set_mode(config.scrsize, config.screenoptions)
    pygame.display.set_caption("Leise rieselt der Schnee")
    pygame.mouse.set_visible(0)
    pygame.event.set_blocked(MOUSEMOTION)
    pygame.mixer.music.set_endevent(USEREVENT)
    #Init sound
    mixer.Init()
    #Init rest
    menu.Init()
    flocke.Init() #Initialise the snow flakes
    extras.Init() #Initialise all these nifty extras...
    snowball.Init()
    player.Init()
    computerplayer.Init()
    game.Init()


def CleanUp():
    pass

def main(args):
    "Leise rieselt der Schnee $Revision: 1.7 $"

    Init()
    if not config.introscroller["skip"]:
        intro.main()
    ende = False
    while not ende:
        ende = menu.main()
        if not ende:
            game.main(menu.no_of_players)
    CleanUp()

if __name__ == '__main__':
    main(sys.argv)
